#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Created by master on 2017/2/26
# 从1开始 步长为3

# (数据源，开始查找的位置)
def binary_search(data_source, find_n):
    mid = int(len(data_source) / 2)  # 找到中间位置
    if int(len(data_source)) >= 1:
        if data_source[mid] > find_n:  # 要找的值在左边
            print("data in left of[%s]" % data_source[mid])
            binary_search(data_source[:mid], find_n)  # 递归
        elif data_source[mid] < find_n:
            print("data in right of[%s]" % data_source[mid])
            binary_search(data_source[mid:], find_n)
        else:
            print("找到了", find_n)
    else:
        print("未找到")


if __name__ == '__main__':
    data = list(range(1, 600, 3))
    print(data)
    binary_search(data, 1)
